/**
 * Created by win10 on 2019/4/30.
 */
var client = require('./../redis_client');
var gameConfig = require("./../config/gameConfig");
var log = require("./../../util/loginfo").getInstand;

var redis_bet_list_key = "game_serverId" + gameConfig.serverId;

//获得重置下注数组
exports.init_bet_list = function init_bet_list() {
    //清除数组
    client.del(redis_bet_list_key);

};

//下注
exports.save_bet = function save_bet(bet_info) {
    client.rpush(redis_bet_list_key, JSON.stringify(bet_info));
};


//获取下注记录
exports.get_bet_list = function get_bet_list() {
    log.info(redis_bet_list_key);
    return new Promise((resolve, reject) => {
        client.lrange(redis_bet_list_key, 0., -1, function (err, lists) {
            log.info('get_bet_list: err :lists: ' +  err + " result list " + lists);
            var result=[];
            if(!err){
                for(var i in lists){
                    result.push(JSON.parse(lists[i]))
                }
                resolve(result)
            }
        });
    })
};




